import 'package:flutter/material.dart';
import 'package:flutter_xyf/model/nav_btn.dart';
import 'package:flutter_xyf/pages/component/app_bar/index.dart';
import 'package:flutter_xyf/pages/component/my_btn/index.dart';
import 'package:flutter_xyf/pages/extend/file_upload/FileUpload.dart';
import 'package:flutter_xyf/pages/extend/provider/provider_demo.dart';
import 'package:flutter_xyf/pages/extend/scrollbar/scroll_demo.dart';
import 'package:flutter_xyf/utils/navigator_util.dart';

import 'inherrite_widget/index.dart';

const debug = true;

class MyExtend extends StatefulWidget {
  MyExtend({Key? key}) : super(key: key);

  @override
  _MyExtendState createState() => _MyExtendState();
}

class _MyExtendState extends State<MyExtend> {
  @override
  void initState() {
    super.initState();
    this.init();
  }

  init() async {}

  @override
  Widget build(BuildContext context) {
    final List<NavBtn> dataList = [
      NavBtn('上拉加载下拉刷新列表', ScrollDemo()),
      NavBtn('状态管理', ProviderDemo()),
      NavBtn('InheritedWidget例子', DemoInhertedPage()),
      NavBtn('上传图片', FileUploadPage()),
    ];
    return Scaffold(
        appBar: MyAppBar(
          title: '扩展',
          isBack: false,
        ),
        body: GridView.builder(
            itemCount: dataList.length,
            gridDelegate:
                SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
            itemBuilder: (_, index) {
              return Padding(
                padding: EdgeInsets.all(10),
                child: MyBtn(
                    text: dataList[index].text,
                    click: () {
                      NavigatorUtil.pushPageByFade(
                          context: context, targetPage: dataList[index].page);
                    }),
              );
            }));
  }
}
